/**
 * LocalTimeSerializer.java 
 * Copyright © 2015-3015, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2015年1月20日
 */
package com.pshare.framework.databind;

import java.io.IOException;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * localTime to json
 */
public class LocalTimeSerializer extends JsonSerializer<LocalTime> {
	
	private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");

	@Override
	public void serialize(LocalTime time, JsonGenerator generator, SerializerProvider provider) throws IOException,
			JsonProcessingException {

		String timeString = time.format(formatter);
		generator.writeString(timeString);
	}
}
